#ifndef DHD_SRP_DATABASE_H
#define DHD_SRP_DATABASE_H 1

#include <string>
#include <stdexcept>

#include "srp.h"
#include <boost/thread.hpp>

struct sqlite3;
struct sqlite3_stmt;

namespace dhd
{
namespace server
{

   struct DatabaseException : std::exception
   {
       const char * static_msg;
       DatabaseException( const char * m ) : static_msg(m) {}
       char const * what() const throw() { return static_msg; }
   };


   class SRPDatabase
   {
       sqlite3      *conn;
       sqlite3_stmt *query;
       boost::mutex  db_mutex;
       
     public:
       
       // throws DatabaseException on error
       SRPDatabase( const std::string & sqlite_db_filename );
       
       ~SRPDatabase();
       
       // users must call srp_verfier_delete() when finished with the returned pointer
       SRPVerifier * get_verifier( const std::string & in_username, const std::string & in_bytes_A,
                                   std::string & out_bytes_s, std::string & out_bytes_B );
       
   };

}//end namespace server
}//end namespace dhd


#endif